package controller.student;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import controller.ServletBase;

import dao.Student;

public class Base extends ServletBase {
    private static final long serialVersionUID = 1L;

    public Base() {
        super();
    }

    protected boolean doInit(HttpServletRequest request,
            HttpServletResponse response) {
        super.doInit(request, response);
        HttpSession session = request.getSession();
        Student.Data d = (Student.Data) session.getAttribute("user-data");
        if (d != null) {
            request.setAttribute("id", d.getId());
            request.setAttribute("no", d.getNo());
            request.setAttribute("name", d.getName());
            request.setAttribute("pwd", d.getPassword());
            request.setAttribute("class", d.get_class());
            view.display("student/head.jsp");
            return true;
        } else {
            view.sendRedirect(request.getContextPath() + "/login");
            return false;
        }
    }

    protected boolean doEnd(HttpServletRequest request,
            HttpServletResponse response) {
        view.display("common/foot.jsp");
        return true;
    }
}
